import request from '@/utils/request'

// 获取结算信息
export const getCheckoutInfo = () => {
  return request('/member/order/pre', 'get')
}

// 再次购买
export const repurchaseOrder = (id) => {
  return request(`/member/order/repurchase/${id}`, 'get')
}

// 添加收货地址
export const addAddress = (form) => {
  return request('/member/address', 'post', form)
}

// 编辑收货地址
export const editAddress = (form) => {
  return request(`/member/address/${form.id}`, 'put', form)
}

// 提交订单
export const submitOrder = (order) => {
  return request('/member/order', 'post', order)
}

// 获取订单详情
export const getOrder = (id) => {
  return request('/member/order/' + id, 'get')
}

// 获取订单列表
export const getOrderList = ({ orderState = 0, page = 1, pageSize = 10 }) => {
  return request('/member/order', 'get', { orderState, page, pageSize })
}

// 取消订单
export const cancelOrder = ({ orderId, cancelReason }) => {
  return request(`/member/order/${orderId}/cancel`, 'put', { cancelReason })
}

// 删除订单
export const deleteOrder = (ids) => {
  return request('/member/order', 'delete', { ids })
}

// 确认收货
export const confirmOrder = (id) => {
  return request(`/member/order/${id}/receipt`, 'delete', id)
}

// 查看物流
export const logisticsOrder = (id) => {
  return request(`/member/order/${id}/logistics`, 'get')
}
